package com.pro.schedule.filter;

import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class ResultUtil {
    public String getResult(int result, String msg) throws Exception {
        if (result > 0) {
            return msg + "成功";
        } else {
            throw new Exception(msg + "失败");
        }
    }

    public Long getUserId(String token) {
        TokenUtil tokenUtil = new TokenUtil();
        Map<String, String> userMap = tokenUtil.parseToken(token);
        return Long.parseLong(userMap.get("userId"));
    }
}
